window.onload = function() {
	var client_2 = document.getElementById("client_2");
	var dialog_border_2 = document.getElementById("dialog_border_2");
	var navHeadimg = document.getElementsByClassName("navHeadimg")[0]
	var navAfterLoginBox = document.getElementsByClassName("navAfterLoginBox")[0]
	client_2.onmouseover = function() {
		dialog_border_2.style.display = "inline-block";
	};
	client_2.onmouseout = function() {
		dialog_border_2.style.display = "none";
	};
	dialog_border_2.onmouseover = function() {
		dialog_border_2.style.display = "inline-block";
	};
	dialog_border_2.onmouseout = function() {
		dialog_border_2.style.display = "none";
	};
	navHeadimg.onmouseover = function() {
		navAfterLoginBox.style.display = "inline-block";
	};
	navHeadimg.onmouseout = function() {
		navAfterLoginBox.style.display = "none";
	};
	navAfterLoginBox.onmouseover = function() {
		navAfterLoginBox.style.display = "inline-block";
	};
	navAfterLoginBox.onmouseout = function() {
		navAfterLoginBox.style.display = "none";
	};
}

function login() {
	var navBeforeLogin = document.getElementById("navBeforeLogin")
	var navAfterLogin = document.getElementById("navAfterLogin")
	navBeforeLogin.style.display = "none"
	navAfterLogin.style.display = "inline-block"
	$('#exampleModal').modal('hide')
}

function quit() {
	var navBeforeLogin = document.getElementById("navBeforeLogin")
	var navAfterLogin = document.getElementById("navAfterLogin")
	navBeforeLogin.style.display = "inline-block"
	navAfterLogin.style.display = "none"
}

$('.form_datetime').datetimepicker({
	format: 'yyyy-mm-dd',
	language: 'zh-CN',
	weekStart: 1,
	autoclose: 1,
	startView: 3,
	minView: 2,
	forceParse: 0,
});
var forPosition;

function changeCourseMessage(a) {
	forPosition = a;
	var oldMessageBox = document.getElementById(a).parentElement.parentElement
	var inputMessageBox = document.getElementById(a).parentElement.parentElement.parentElement.children[0]
	inputMessageBox.children[0].value = oldMessageBox.children[0].innerText
	oldMessageBox.classList.add("f-dn");
	inputMessageBox.classList.remove("f-dn");
}

function cancelChange() {
	var oldMessageBox = document.getElementById(forPosition).parentElement.parentElement
	var inputMessageBox = document.getElementById(forPosition).parentElement.parentElement.parentElement.children[0]
	inputMessageBox.classList.add("f-dn");
	oldMessageBox.classList.remove("f-dn");
}

function saveChange() {
	var oldMessageBox = document.getElementById(forPosition).parentElement.parentElement
	var inputMessageBox = document.getElementById(forPosition).parentElement.parentElement.parentElement.children[0]
	oldMessageBox.children[0].innerText = inputMessageBox.children[0].value
	inputMessageBox.classList.add("f-dn");
	oldMessageBox.classList.remove("f-dn");
}

function setHeadImg() {
	var showHeadImg = document.getElementById("showHeadImg")
	var changeHeadImg = document.getElementById("changeHeadImg")
	var newUrl = getObjectURL(changeHeadImg.files[0])
	showHeadImg.src = newUrl
}

function getObjectURL(file) {
	let url = null;
	if(window.createObjectURL != undefined) { // basic
		url = window.createObjectURL(file);
	} else if(window.webkitURL != undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file);
	} else if(window.URL != undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file);
	}
	return url;
}